<?php
require("funkcie.php");

if(isset($_POST["username"]) && $_POST["username"] != "" //&&
	/*isset($_POST["password"]) && $_POST["password"] != ""*/) {

	$sql = connectDB();

	$query = sprintf("SELECT password FROM users WHERE name = '%s' LIMIT 1", 
				mysql_real_escape_string($_POST["username"]));

	$res = mysql_query($query, $sql);

	if(mysql_num_rows($res) < 1) {
		echo "username";
	} else {
		$row = mysql_fetch_array($res);
		$pass = $row["password"];
		if($pass != sha1($_POST["password"])) { 
			echo "password";
		} else {
			echo "index1.php";
			session_start();
			$_SESSION['success'] = true;
		}
	}
	disconnectDB($sql);
}
?>